<%- include('common/head.ejs') %>

<h1>收件箱</h1>

<div id="inbox">
    <div class="margin-left-20 margin-right-20">
        <button class="btn btn-warning" onclick="delMail('/')">删除</button>
        <table class="table table-striped">
            <thead>
            <tr>
                <th class="col-sm-1">
                    <input type="checkbox" id="selectAll">
                </th>
                <th class="col-sm-1"><span class="glyphicon glyphicon-envelope "></span></th>
                <th class="col-sm-1">发件人</th>
                <th class="col-sm-7">主题</th>
                <th class="col-sm-2">时间</th>
            </tr>
            </thead>
            <tbody>
            <% mails.forEach(function(mail){%>
            <tr >
                <td><input type="checkbox" name="checked" value="<%= mail._id %>"></td>
                <td><span class="glyphicon glyphicon-envelope <%= mail.isread == '1' ? 'color-success' : 'color-fail' %>" ></span></td>
                <td><%= mail.inMail.email %></td>
                <td id="mouseMove" onclick="showMail('inbox','<%= mail._id %>','<%= mail.inMail.email %>','<%= mail.title %>','<%= mail.text %>','<%= mail.isread %>')"><%= mail.title%></td>
                <td><%= mail.updated_at%></td>
            </tr>
            <% }) %>
            </tbody>
        </table>
        <button class="btn btn-warning margin-top-20" onclick="delMail('/')">删除</button>
        <div class="pull-right">
            <ul class="pager">
                <span class="margin-right-20"><%= page + '/' + pageTotal  %></span>
                <li class="<%= page == '1' ? 'hide' : null%>"><a href="/mail/?page=<%= JSON.parse(page) - 1%>">上一页</a></li>
                <li class="<%= page == pageTotal ? 'hide' : ''%>"><a href="/mail/?page=<%= JSON.parse(page) + 1%>">下一页</a></li>
                <li><input type="text" id="page" class="page"></li>
                <li><a href="JavaScript:getPageData('<%= pageTotal %>','/')">跳转</a></li>
            </ul>
        </div>
    </div>
</div>
<div id="edit" class="hide">
    <div class="main-background">
        <form id="inboxEdit" class="form-horizontal margin-left-20 margin-right-20">
            <div class="form-group">
                <div class="col-sm-offset-2">
                    <button type="button" class="btn btn-primary" onclick="jumpPage('/mail/')">关闭</button>
                </div>
                <input class="hide" id="mailId" name="mailId" />
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2" for="toMail">发件人</label>

                <div class="col-sm-9">
                    <input class="form-control" id="toMail" name="toMail" type="text" disabled >
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2" for="title">主题</label>

                <div class="col-sm-9">
                    <input class="form-control" id="title" name="title" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-sm-2">正文</label>
                <div class="col-sm-9">
                    <div id="editText"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2">
                    <p>发件人： <%= user.email %></p>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2">
                    <button type="button" class="btn btn-primary" onclick="jumpPage('/mail/')">关闭</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="/common/wangEditor/wangEditor.js"></script>
<script type="text/javascript" src="/javascripts/inbox.js"></script>
<script type="text/javascript" src="/javascripts/draft.js" ></script>

<%- include('common/footer') %>